package cn.huanzi.qch.baseadmin.travel.front.controller;

import cn.huanzi.qch.baseadmin.travel.scenic.service.ScenicService;
import cn.huanzi.qch.baseadmin.travel.scenic.vo.ScenicVo;
import cn.huanzi.qch.baseadmin.travel.thotel.service.THotelService;
import cn.huanzi.qch.baseadmin.travel.thotel.vo.THotelVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * 前台页面跳转
 */

@Slf4j
@RestController
@RequestMapping("/travel")
public class FrontEndController {
    @Autowired
    private THotelService tHotelService;

    @Autowired
    private ScenicService scenicService;

    @GetMapping("/index")
    public ModelAndView toIndex(ModelAndView modelAndView) {
        List<THotelVo> hotelList = tHotelService.findAll();
        List<ScenicVo> scenicList = scenicService.findAll();
        modelAndView.addObject("hotels", hotelList);
        modelAndView.addObject("sciences", scenicList);
        modelAndView.setViewName("travel/front-end/index");
        return modelAndView;
    }

    @GetMapping("/hotel")
    public ModelAndView toHotelReservation(ModelAndView modelAndView) {
        List<THotelVo> hotelList = tHotelService.findAll();
        modelAndView.addObject("hotels", hotelList);
        modelAndView.setViewName("travel/front-end/hotelReservation");
        return modelAndView;
    }

//    @GetMapping("/hotel/reservation")
//    public ModelAndView toReservation() {
//        return new ModelAndView("travel/front-end/reservation");
//    }

//    @GetMapping("/scenic")
//    public ModelAndView toScenic() {
//        return new ModelAndView("redirect:/travel/scenic/");
//    }

    @GetMapping("/about")
    public ModelAndView toAbout() {
        return new ModelAndView("travel/front-end/about");
    }

}
